<template>
  <div style="padding-bottom: 30px;">
    <ShareCircleCategory
      :circle-list="pagination.list"
      category="1"
      :loading="firstLoading"
      @delete-circle="deleteCircle"
    />
  </div>
</template>

<script>
import ShareCircleCategory from '../components/ShareCircleCategory'
import userMixin from '~/mixin/user'
import ScrollLoadEvent from '~/util/scrollLoadEvent'
export default {
  name: 'UserCircle',
  components: { ShareCircleCategory },
  mixins: [userMixin],

  created () {
    this.findUserActionList('/gimishare/api/v1/shares')
  },

  mounted () {
    this.scrollLoadEvent = new ScrollLoadEvent(
      this.findUserActionList.bind(this, '/gimishare/api/v1/shares', true)
    )
    this.$nextTick(() => {
      this.scrollLoadEvent.bindScrollEvent()
    })
  },

  methods: {
    deleteCircle (circleId) {
      const idx = this.pagination.list.findIndex((o) => o.id === circleId)
      if (idx > -1) {
        this.pagination.list.splice(idx, 1)
      }
    }
  }
}
</script>
